package com.mutual.assistance.user.converter;


import com.mutual.assistance.user.model.bo.UserBO;
import com.mutual.assistance.user.model.bo.UserMessageBO;
import com.mutual.assistance.user.model.dto.*;
import com.mutual.assistance.user.model.po.*;
import com.mutual.assistance.user.model.vo.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * @author chenyuxin
 * @version 1.0
 * @description 认证实体类之间的转换
 * @date 2023/4/15 21:14
 */
@Mapper(componentModel = "spring")
public interface UserConverterParams {

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "status", constant = "1")
    @Mapping(target = "sort", ignore = true)
    @Mapping(target = "level", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "isMenu", ignore = true)
    MenuPO addMenuVO2MenuPO(AddMenuVO addMenuVO);

    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "id", source = "menuId")
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "isMenu", expression = "java(updateMenuVO.getIsMenu())")
    @Mapping(target = "status", expression = "java(String.valueOf(updateMenuVO.getIsMenu()))")
    MenuPO updateMenuVO2MenuPO(UpdateMenuVO updateMenuVO);

    MenuDTO menuPO2MenuDTO(MenuPO menuPO);

    @Mapping(target = "menuDTOList", ignore = true)
    MenusDTO menuDTO2MenusDTO(MenuDTO menuDTO);

    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "status", constant = "1")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    RolePO rolePO2AddRoleVO(AddRoleVO addRoleVO);

    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "id", source = "roleId")
    @Mapping(target = "createTime", ignore = true)
    RolePO updateRoleVO2RolePO(UpdateRoleVO updateRoleVO);

    @Mapping(target = "menuDTOList", ignore = true)
    RoleDTO rolePO2RoleDTO(RolePO rolePO);

    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "status", constant = "1")
    @Mapping(target = "star", constant = "3")
    @Mapping(target = "qq", ignore = true)
    @Mapping(target = "pic", ignore = true)
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "description", constant = "这个人很懒，什么都没有留下")
    @Mapping(target = "credit", constant = "50")
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "cellphone", ignore = true)
    UserPO registerUserVo2UserPO(RegisterUserVO register);

    UserBO userPO2UserBO(UserPO userPO);

    UserDTO userPO2UserDTO(UserPO userPO);

    List<UserDTO> userPO2UserDTOList(List<UserPO> userPOList);

    @Mapping(target = "username", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "status", ignore = true)
    @Mapping(target = "star", ignore = true)
    @Mapping(target = "password", ignore = true)
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "credit", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    UserPO updateUserPersonalParamsVO2UserPO(UpdateUserPersonalParamsVO updateUserPersonalParamsVO);

    @Mapping(target = "username", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    UserPO updateUserParamsVO2UserPO(UpdateUserParamsVO updateUserParamsVO);

    @Mapping(target = "roleDTOList", ignore = true)
    UserAndRoleDTO userPO2UserAndRoleDTO(UserPO userPO);

    RoleSimpleDto rolePO2RoleSimpleDto(RolePO rolePO);

    @Mapping(target = "userId", expression = "java(Long.valueOf(addUserAndRoleParamsVO.getUserId()))")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "creator", source = "adminId")
    @Mapping(target = "createTime", expression = "java(java.time.LocalDateTime.now())")
    UserRolePO addUserAndRoleParamsVO2UserRolePO(AddUserAndRoleParamsVO addUserAndRoleParamsVO);

    UserIntegralDTO userDTO2UserIntegralDTO(UserDTO userDTO);

    @Mapping(target = "updateTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "status", constant = "005001")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", expression = "java(java.time.LocalDateTime.now())")
    UserNoticePO userMessageBO2UserNoticePO(UserMessageBO userMessageBO);

    UserNoticeDTO userNoticePO2UserNoticeDTO(UserNoticePO userNoticePO);

    List<UserNoticeDTO> userNoticePO2UserNoticeDTOList(List<UserNoticePO> userNoticePO);
}
